
#include "_AdbCheckCallback.h"
#include "AnAdbServer.h"

#include <iostream>

_AdbCheckCallback::_AdbCheckCallback(AnMainwin * amw) {
    anMainwin = amw;
    dia = new AnAdbchoseDialog(anMainwin);
    QObject::connect(dia, SIGNAL(sendYesCheck(QString)), this, SLOT(adb_file_chose(QString)));
}

void _AdbCheckCallback::response(QJsonObject an_response) {
    AnGlobal::log_show(an_response, DESP_RESP);
    std::cout << "response" << std::endl;
    switch (an_response.value(DATA).toObject().value(RESULT).toInt(-1)) {
    case 1:
        adb_installed = YES;
        emit adb_seted();
        break;
    case 0:
        adb_installed = NO;
        dia->show();
        break;
    default:
        dia->show();
        break;
    }

}


void _AdbCheckCallback::adb_file_chose(QString path)
{
    std::cout << "PP " << path.toUtf8().data() << std::endl;
    adb_path = path;
    QJsonObject resq;
    resq.insert(NAME, QJsonValue("adb_check"));
    adb_server->adbServerManager(resq, this);
}

